package com.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.test01.service.User01Service;
import com.test02.service.User02Service;

@RestController
public class IndexController {
	private static final Logger LOG = LoggerFactory.getLogger(IndexController.class);
	@Autowired
	private User01Service user1Service;
	@Autowired
	private User02Service user2Service;

	@Transactional
	@RequestMapping("/user1Service")
	public String user1Service() {
		user1Service.addUser("db user001", 19);
		user2Service.addUser("db user002", 19);
		return "success";
	}
	
	@Transactional
	@RequestMapping("/user2Service")
	public String user2Service() {
		user1Service.addUser("db user001", 19);
		int i=1/0;
		user2Service.addUser("db user002", 19);
		return "success";
	}
	
	@Transactional
	@RequestMapping("/user3Service")
	public String user3Service() {
		user2Service.addUser("db user002", 19);
		int i=1/0;
		user1Service.addUser("db user001", 19);
		return "success";
	}

}
